﻿var sessionRecordJqGrid =
    {
		/**初始化*/
		init:function(orderid){
			//初始化Grid数据
            jQuery("#sessionRecordListTable").jqGrid({
                url: basePath + "/reserveSession/queryReserveSession",
                datatype: 'json',
    			mtype: 'POST',
                postData: {
                    orderid: orderid
                },
                shrinkToFit:true,
                width:'700px',
                height:'100%',
                scrollrows: false,
                colNames:['会话开始时间','会话结束时间','会话时长'],
    			colModel:[
    				{name:'startTime',index:'startTime', sortable:false, editable:false, align:"center",formatter:
                        function(cellvalue, options, rowObject){
                            return DateUtil.format(new Date(cellvalue), "yyyy-MM-dd HH:mm:ss");
                    }},
    				{name:'endTime',index:'endTime', sortable:false, editable:false, align:"center",formatter:
                        function(cellvalue, options, rowObject){
                            return DateUtil.format(new Date(cellvalue), "yyyy-MM-dd HH:mm:ss");
                        }},
    				{name:'timeLength',index:'timeLength', sortable:false, editable:false, align:"center"}
    			],
    			viewrecords : true,
//                rowNum:10,
//                rowList:[10, 20, 30],
//                pager:"#sessionRecordListPager",
                altRows: true,
    			multiselect: false,
    	        multiboxonly: false,
                jsonReader:{
                    root:"result",
                    total:"totalpages",
                    page:"currpage",
                    records:"totalrecords",
                    repeatitems:false
                },

                sortable: false,
                loadComplete : function() {
					var table = this;
					setTimeout(function(){
						styleCheckbox(table);
						
						updateActionIcons(table);
						updatePagerIcons(table);
						enableTooltips(table);
					}, 0);
				},
                autowidth: true
            }).navGrid('#productQueryPager',{
            	edit:false,
            	editicon : 'icon-pencil blue',
            	add:false,
            	addicon : 'icon-plus-sign purple',
            	del:false,
            	delicon : 'icon-trash red',
            	search:false,
            	searchicon : 'icon-search orange',
            	refresh:true,
            	refreshicon : 'icon-refresh green'
            });

            $("#searchBtn").click(function () {

            	$("#productQueryTable").jqGrid("setGridParam",
        			{postData: {
                        productCode: $("#productCode").val(),
                        sku: $("#sku").val(),
                        productName: $("#productName").val(),
                        productStatus: $("#productStatus").val(),
                        oneCategory: $("#oneCategory").val(),
                        twoCategory: $("#twoCategory").val(),
                        threeCategory: $("#threeCategory").val(),
                        productChannel: $("#productChannel").val()
        			}}
            	).trigger("reloadGrid",[{page:1}]);
            });
		}
    };



$(function(){

    //初始化datagrid
    var currOrderid = $("#currOrderid").val();
    if(currOrderid!=''){
        sessionRecordJqGrid.init(currOrderid);
    }
    $("#sessionRecordListTable").setGridWidth($(window).width() - 50);
    $("#sessionRecordListTable").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
})
